package com.t194.controller;

import com.t194.pojo.Permission;
import com.t194.pojo.User;
import com.t194.service.PermissionService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class IndexController {
    @Resource
    private PermissionService permissionService;

    @GetMapping("/index")
    public String index(Model model){
        Subject subject= SecurityUtils.getSubject();
        Session session= subject.getSession();
        User loginUser= (User) subject.getPrincipal();
        session.setAttribute("loginUser",loginUser);
        List<Permission>menus=permissionService.searchPermissionList();
        model.addAttribute("menus",menus);
        return "index";
    }
}
